import request from '@/utils/http'
import { BaseResult } from '@/types/axios'

interface ListParams {
  pageNum?: number
  pageSize?: number
  sourceName: string,
  sourceCode: string,
  status: string | number,
}

interface DeleteParams {
  id?: number
}

interface CustomerSourceData {
  id?: string | number  // 使 id 成为可选属性
  sourceName?: string
  sourceCode?: string
  status?: string | number
}

export class CustomerLevelApi {
  // 登录
  static getTableData(params: ListParams) {
    return request.post<BaseResult>({
      url: '/customer/source/list',
      params
    })
  }
  // 创建新的客户来源
  static createCustomerSource(data: CustomerSourceData) {
    return request.post<BaseResult>({
      url: '/customer/source/create',
      data
    })
  }
  // 更新客户来源
  static updateCustomerSource(data: CustomerSourceData) {
    return request.put<BaseResult>({
      url: '/customer/source/update',
      data
    })
  }
  // 删除客户来源
  static deleteCustomerSource(params: DeleteParams) {
    return request.post<BaseResult>({
      url: '/customer/source/delete',
      params
    })
  }
}
